home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2007 December / PCWKCD1207B.iso / Blogowanie poza sfera / Flock 0.9.1.3 stable / flock-0.9.1.3.en-US.win32.exe / flock / chrome / browser.jar / content / browser / safeMode.js < prev    next >
Text File  |  2007-02-10  |  4KB  |  104 lines

  1. //@line 39 "/cygdrive/K/tinderbuild/src/flock/mozilla/browser/base/content/safeMode.js"
  2.  
  3. function restartApp() {
  4.   var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"]
  5.                              .getService(Components.interfaces.nsIAppStartup);
  6.   appStartup.quit(appStartup.eForceQuit | appStartup.eRestart);
  7. }
  8.  
  9. function clearAllPrefs() {
  10.   var prefService = Components.classes["@mozilla.org/preferences-service;1"]
  11.                               .getService(Components.interfaces.nsIPrefService);
  12.   prefService.resetUserPrefs();
  13.  
  14.   // Remove the pref-overrides dir, if it exists
  15.   try {
  16.     var fileLocator = Components.classes["@mozilla.org/file/directory_service;1"]
  17.                                 .getService(Components.interfaces.nsIProperties);
  18.     const NS_APP_PREFS_OVERRIDE_DIR = "PrefDOverride";
  19.     var prefOverridesDir = fileLocator.get(NS_APP_PREFS_OVERRIDE_DIR,
  20.                                            Components.interfaces.nsIFile);
  21.     prefOverridesDir.remove(true);
  22.   } catch (ex) {
  23.     Components.utils.reportError(ex);
  24.   }
  25. }
  26.  
  27. function restoreDefaultBookmarks() {
  28.   var prefBranch  = Components.classes["@mozilla.org/preferences-service;1"]
  29.                               .getService(Components.interfaces.nsIPrefBranch);
  30.   prefBranch.setBoolPref("browser.bookmarks.restore_default_bookmarks", true);
  31. }
  32.  
  33. function deleteLocalstore() {
  34.   const nsIDirectoryServiceContractID = "@mozilla.org/file/directory_service;1";
  35.   const nsIProperties = Components.interfaces.nsIProperties;
  36.   var directoryService =  Components.classes[nsIDirectoryServiceContractID]
  37.                                     .getService(nsIProperties);
  38.   var localstoreFile = directoryService.get("LStoreS", Components.interfaces.nsIFile);
  39.   if (localstoreFile.exists())
  40.     localstoreFile.remove(false);
  41. }
  42.  
  43. function disableAddons() {
  44.   // Disable addons
  45.   const nsIUpdateItem = Components.interfaces.nsIUpdateItem;
  46.   var em = Components.classes["@mozilla.org/extensions/manager;1"]
  47.                      .getService(Components.interfaces.nsIExtensionManager);
  48.   var type = nsIUpdateItem.TYPE_EXTENSION + nsIUpdateItem.TYPE_LOCALE +
  49.              nsIUpdateItem.TYPE_PLUGIN;
  50.   var items = em.getItemList(type, { });
  51.   for (var i = 0; i < items.length; ++i)
  52.     em.disableItem(items[i].id);
  53.  
  54.   // Select the default theme
  55.   var prefB = Components.classes["@mozilla.org/preferences-service;1"]
  56.                         .getService(Components.interfaces.nsIPrefBranch);
  57.   prefB.clearUserPref("general.skins.selectedSkin");
  58. }
  59.  
  60. function restoreDefaultSearchEngines() {
  61.   var searchService = Components.classes["@mozilla.org/browser/search-service;1"]
  62.                                 .getService(Components.interfaces.nsIBrowserSearchService);
  63.  
  64.   searchService.restoreDefaultEngines();
  65. }
  66.  
  67. function onOK() {
  68.   try {
  69.     if (document.getElementById("resetUserPrefs").checked)
  70.       clearAllPrefs();
  71.     if (document.getElementById("resetBookmarks").checked)
  72.       restoreDefaultBookmarks();
  73.     if (document.getElementById("resetToolbars").checked)
  74.       deleteLocalstore();
  75.     if (document.getElementById("disableAddons").checked)
  76.       disableAddons();
  77.     if (document.getElementById("restoreSearch").checked)
  78.       restoreDefaultSearchEngines();
  79.   } catch(e) {
  80.   }
  81.  
  82.   restartApp();
  83. }
  84.  
  85. function onCancel() {
  86.   var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"]
  87.                              .getService(Components.interfaces.nsIAppStartup);
  88.   appStartup.quit(appStartup.eForceQuit);
  89. }
  90.  
  91. function onLoad() {
  92.   document.getElementById("tasks")
  93.           .addEventListener("CheckboxStateChange", UpdateOKButtonState, false);
  94. }
  95.  
  96. function UpdateOKButtonState() {
  97.   document.documentElement.getButton("accept").disabled = 
  98.     !document.getElementById("resetUserPrefs").checked &&
  99.     !document.getElementById("resetBookmarks").checked &&
  100.     !document.getElementById("resetToolbars").checked &&
  101.     !document.getElementById("disableAddons").checked &&
  102.     !document.getElementById("restoreSearch").checked;
  103. }
  104.